﻿using System;
using System.Collections.Generic;
using System.Data;
using System.Data.SqlTypes;
using System.Linq;
using System.Text;


namespace nadModel.pad
{
    public partial class PartOprEntityProcess : AbstractEntityProcess
    {

        public override AbstractEntity[] PackEntity(object obj)
        {
            //pack entries
            List<PartOprEntity> entryList = new List<PartOprEntity>();

            PartOprEntity entry;
            try
            {
                DataTable dt = (DataTable)obj;
                if (dt == null)
                {
                    return null;
                }

                foreach (DataRow item in dt.Rows)
                {
                    entry = new PartOprEntity();
                    entry.Company = item[PartOprEntity.COMPANY].ToString();
                    entry.PartNum = item[PartOprEntity.PARTNUM].ToString();
                    entry.OpCode = item[PartOprEntity.OPCODE].ToString();
                    entry.OpDesc = item[PartOprEntity.OPDESC].ToString();
                    entry.OprSeq = item[PartOprEntity.OPRSEQ].ToString();
                    entry.RevisionNum = item[PartOprEntity.REVISIONNUM].ToString();                    
                    entryList.Add(entry);
                }
            }
            catch (Exception ex)
            {
                Log("ERROR: error packing entity", LogLevel.FATAL);
                Log(ex.ToString(), LogLevel.FATAL);
                throw ex;
            }
            return (AbstractEntity[])entryList.ToArray();

        }
    }
}
